package com.photoeditor.demo.model.preference;

import android.text.TextUtils;

import com.common.base.log.DLog;
import com.photoeditor.demo.model.bean.face.BaseFaceResultBean;
import com.photoeditor.demo.util.DateUtils;
import com.photoeditor.demo.util.FileUtil;

import java.io.File;
import java.util.Date;

/**
 * Created by winn on 17/4/13.
 */

public class SPDataManager {

    public static final String TAG = SPDataManager.class.getSimpleName();

    private static boolean sIsFirstStart = false;

    public static void init() {
        sIsFirstStart = SpUtils.obtain().getBoolean(SpConstant.IS_APP_FIRST_START, true);
        SpUtils.obtain().save(SpConstant.IS_APP_FIRST_START, false);
    }

    public static boolean isFirstStart() {
        return sIsFirstStart;
    }

    public static boolean isInitDBDataSuccess() {
        return SpUtils.obtain().getBoolean(SpConstant.INIT_DB_DATA_SUCCESS, false);
    }

    public static void setInitDBDataSuccess(boolean success) {
        SpUtils.obtain().save(SpConstant.INIT_DB_DATA_SUCCESS, success);
    }

    public static int getAppInstallVersion() {
        return SpUtils.obtain().getInt(SpConstant.APP_INSTALL_VERSION, 0);
    }

    public static void setAppInstallVersion(int version) {
        SpUtils.obtain().save(SpConstant.APP_INSTALL_VERSION, version);
    }

//    public static boolean isTouchTakePhoto() {
//        return SpUtils.obtain().getBoolean(SpConstant.TOUCH_2_TAKE_PHOTO, false);
//    }
//
//    public static void setTouchTakePhoto(boolean able) {
//        SpUtils.obtain().save(SpConstant.TOUCH_2_TAKE_PHOTO, able);
//    }

    public static boolean isCropSquare() {
        return SpUtils.obtain().getBoolean(SpConstant.BITMAP_CROP_SQUARE, false);
    }

    public static void setCropSquare(boolean square) {
        SpUtils.obtain().save(SpConstant.BITMAP_CROP_SQUARE, square);
    }

//    public static boolean isCropRect() {
//        return SpUtils.obtain().getBoolean(SpConstant.BITMAP_CROP_RECT, true);
//    }
//
//    public static void setCropRect(boolean rect) {
//        SpUtils.obtain().save(SpConstant.BITMAP_CROP_RECT, rect);
//    }
//
//    public static int getOnlyTwoCollageRatio(int defaultValue) {
//        return SpUtils.obtain().getInt(SpConstant.ONLY_TWO_COLLAGE_RATIO, defaultValue);
//    }
//
//    public static void setOnlyTwoCollageRatio(int value) {
//        SpUtils.obtain().save(SpConstant.ONLY_TWO_COLLAGE_RATIO, value);
//    }

    public static String getPhotoSaveLocation() {
        return SpUtils.obtain().getString(SpConstant.PHOTO_SAVE_LOCATION, FileUtil.DICM_ROOT_PATH + File.separator + "Camera");
    }

    public static void setPhotoSaveLocation(String location) {
        SpUtils.obtain().save(SpConstant.PHOTO_SAVE_LOCATION, location);
    }

    public static int getMaxTextureSize() {
        return SpUtils.obtain().getInt(SpConstant.MAX_TEXTURE_SIZE, 0);
    }

    public static void setMaxTextureSize(int size) {
        SpUtils.obtain().save(SpConstant.MAX_TEXTURE_SIZE, size);
    }

//    public static boolean isCollageWithFrame() {
//        return SpUtils.obtain().getBoolean(SpConstant.COLLAGE_WITH_FRAME, false);
//    }
//
//    public static void setCollageWithFrame(boolean value) {
//        SpUtils.obtain().save(SpConstant.COLLAGE_WITH_FRAME, value);
//    }

    public static boolean isPlayShutterSound() {
        return SpUtils.obtain().getBoolean(SpConstant.PLAY_SHUTTER_SOUND, true);
    }

    public static void setPlayShutterSounde(boolean play) {
        SpUtils.obtain().save(SpConstant.PLAY_SHUTTER_SOUND, play);
    }

//    public static int getTakeVideoCount() {
//        return SpUtils.obtain().getInt(SpConstant.TAKE_VIDEO_COUNT, 0);
//    }
//
//    public static void setTakeVideoCount(int count) {
//        SpUtils.obtain().save(SpConstant.TAKE_VIDEO_COUNT, count);
//    }
//
//    public static int getTakeMotionCount() {
//        return SpUtils.obtain().getInt(SpConstant.TAKE_MOTION_COUNT, 0);
//    }
//
//    public static void setTakeMotionCount(int count) {
//        SpUtils.obtain().save(SpConstant.TAKE_MOTION_COUNT, count);
//    }

    public static int getEditCount() {
        return SpUtils.obtain().getInt(SpConstant.EDIT_COUNT, 0);
    }

    public static void setEditCount(int count) {
        SpUtils.obtain().save(SpConstant.EDIT_COUNT, count);
    }

//    public static int getShareCount() {
//        return SpUtils.obtain().getInt(SpConstant.SHARE_COUNT, 0);
//    }
//
//    public static void setShareCount(int count) {
//        SpUtils.obtain().save(SpConstant.SHARE_COUNT, count);
//    }
//
//    public static boolean isShowLocation() {
//        return SpUtils.obtain().getBoolean(SpConstant.SHOW_LOCATION, false);
//    }
//
//    public static void setShowLocation(boolean showLocation) {
//        SpUtils.obtain().save(SpConstant.TAKE_VIDEO_COUNT, showLocation);
//    }

    public static int getTakePictureCount() {
        return SpUtils.obtain().getInt(SpConstant.TAKE_PICTURE_COUNT, 0);
    }

    public static void setTakePictureCount(int count) {
        SpUtils.obtain().save(SpConstant.TAKE_PICTURE_COUNT, count);
    }

//    public static boolean isHdrOn() {
//        return SpUtils.obtain().getBoolean(SpConstant.HDR_ON, false);
//    }
//
//    public static void setHdrOn(boolean on) {
//        SpUtils.obtain().save(SpConstant.HDR_ON, on);
//    }
//
//    public static boolean isVignetteOn() {
//        return SpUtils.obtain().getBoolean(SpConstant.VIGNETTE_ON, false);
//    }
//
//    public static void setVignetteOn(boolean on) {
//        SpUtils.obtain().save(SpConstant.VIGNETTE_ON, on);
//    }
//
//    public static int getBlurState() {
//        return SpUtils.obtain().getInt(SpConstant.BLUR_STATE, 0);
//    }
//
//    public static void setBlurState(int state) {
//        SpUtils.obtain().save(SpConstant.BLUR_STATE, state);
//    }


//    public static void setResolutionById(int cameraId, String resolution) {
//        SpUtils.obtain().save("camera_resolution_" + cameraId, resolution);
//    }
//
//    public static String getResolutionById(int cameraId) {
//        return SpUtils.obtain().getString("camera_resolution_" + cameraId, "");
//    }
//
//    public static String getVideoQualityById(int cameraId) {
//        return SpUtils.obtain().getString("video_quality_" + cameraId, "");
//    }
//
//    public static void setVideoQualityById(int cameraId, String quality) {
//        SpUtils.obtain().save("video_quality_" + cameraId, quality);
//    }
//
//    public static String getCameraSizesFingerPrint() {
//        return SpUtils.obtain().getString(SpConstant.CAMERA_SIZE_FINGERPRINT, "");
//    }
//
//    public static void setCameraSizesFingerPrint(String fingerPrint) {
//        SpUtils.obtain().save(SpConstant.CAMERA_SIZE_FINGERPRINT, fingerPrint);
//    }
//
//    public static String getVideoBitrate() {
//        return SpUtils.obtain().getString(SpConstant.VIDEO_BITRATE, "default");
//    }
//
//    public static void setVideoBitrate(String bitrage) {
//        SpUtils.obtain().save(SpConstant.VIDEO_BITRATE, bitrage);
//    }
//
//    public static String getVideoFps() {
//        return SpUtils.obtain().getString(SpConstant.VIDEO_FPS, "default");
//    }
//
//    public static void setVideoFps(String fps) {
//        SpUtils.obtain().save(SpConstant.VIDEO_FPS, fps);
//    }
//
//    public static String getPreviewSize() {
//        return SpUtils.obtain().getString(SpConstant.PREVIEW_SIZE, "preference_preview_size_from_display");
//        //return SpUtils.obtain().getString(SpConstant.PREVIEW_SIZE, "preference_preview_size_default");
//    }
//
//    public static void setPreviewSize(String size) {
//        SpUtils.obtain().save(SpConstant.PREVIEW_SIZE, size);
//    }
//
//    public static String getRotatePreview() {
//        return SpUtils.obtain().getString(SpConstant.ROTATE_PREVIEW, "0");
//    }
//
//    public static void setRotatePreview(String size) {
//        SpUtils.obtain().save(SpConstant.ROTATE_PREVIEW, size);
//    }
//
//    public static String getGridInfo() {
//        return SpUtils.obtain().getString(SpConstant.GRID_INFO, "");
//    }
//
//    public static void setGridInfo(String gridInfo) {
//        SpUtils.obtain().save(SpConstant.GRID_INFO, gridInfo);
//    }
//
//    public static boolean getShowMotionPressTip() {
//        return SpUtils.obtain().getBoolean(SpConstant.SHOW_MOTION_PRESS_TIP, true);
//    }
//
//    public static void setShowMotionPressTip(boolean show) {
//        SpUtils.obtain().save(SpConstant.SHOW_MOTION_PRESS_TIP, show);
//    }
//
//    public static String getFlashValue() {
//        return SpUtils.obtain().getString(SpConstant.FLASH_VALUE, "flash_off");
//    }
//
//    public static void setFlashValue(String value) {
//        SpUtils.obtain().save(SpConstant.FLASH_VALUE, value);
//    }
//
//    public static String getTakePhotoTimer() {
//        return SpUtils.obtain().getString(SpConstant.TAKE_PHOTO_TIME, "0");
//    }
//
//    public static void setTakePhotoTimer(String time) {
//        SpUtils.obtain().save(SpConstant.TAKE_PHOTO_TIME, time);
//    }
//
//    public static String getRecordAudioSrc() {
//        return SpUtils.obtain().getString(SpConstant.RECORD_AUDIO_SRC, "audio_src_camcorder");
//    }
//
//    public static void setRecordAudioSrc(String src) {
//        SpUtils.obtain().save(SpConstant.RECORD_AUDIO_SRC, src);
//    }
//
//    public static boolean getMirrorFrontCamera() {
//        return SpUtils.obtain().getBoolean(SpConstant.MIRROR_FRONT_CAMERA, true);
//    }
//
//    public static void setMirrorFrontCamera(boolean mirror) {
//        SpUtils.obtain().save(SpConstant.MIRROR_FRONT_CAMERA, mirror);
//    }
//
//    public static boolean isFrontCamera() {
//        return SpUtils.obtain().getBoolean(SpConstant.FRONT_CAMERA, false);
//    }
//
//    public static void setFrontCamera(boolean front) {
//        SpUtils.obtain().save(SpConstant.FRONT_CAMERA, front);
//    }
//
//    public static long getCollageDelayTime() {
//        return SpUtils.obtain().getLong(SpConstant.COLLAGE_DELAY_TIME, 0);
//    }
//
//    public static void setCollageDelayTime(long time) {
//        SpUtils.obtain().save(SpConstant.COLLAGE_DELAY_TIME, time);
//    }
//
//    public static boolean getShowThumbnailAnimation() {
//        return SpUtils.obtain().getBoolean(SpConstant.SHOW_THUMBNAIL_ANIMATION, true);
//    }
//
//    public static void setShowThumbnailAnimation(boolean show) {
//        SpUtils.obtain().save(SpConstant.SHOW_THUMBNAIL_ANIMATION, show);
//    }
//
//    public static boolean getGpsDirection() {
//        return SpUtils.obtain().getBoolean(SpConstant.GPS_DIRECTION, false);
//    }
//
//    public static void setGpsDirection(boolean show) {
//        SpUtils.obtain().save(SpConstant.GPS_DIRECTION, show);
//    }
//
//    public static String getImageQuality() {
//        return SpUtils.obtain().getString(SpConstant.IMAGE_QUALITY, "100");
//    }
//
//    public static void setImageQuality(String quality) {
//        SpUtils.obtain().save(SpConstant.IMAGE_QUALITY, quality);
//    }
//
//    public static boolean getShowTiltshiftClickTips() {
//        return SpUtils.obtain().getBoolean(SpConstant.TILTSHIFT_CLICK_TIPS, false);
//    }
//
//    public static void setShowTiltshiftClickTips(boolean show) {
//        SpUtils.obtain().save(SpConstant.TILTSHIFT_CLICK_TIPS, show);
//    }

    public static boolean getHasNewFilter() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_NEW_FILTER, true);
    }

    public static void setHasNewFilter(boolean show) {
        SpUtils.obtain().save(SpConstant.HAS_NEW_FILTER, show);
    }

//    public static boolean getHasNewMarking() {
//        return SpUtils.obtain().getBoolean(SpConstant.HAS_NEW_MARKING, true);
//    }
//
//    public static void setHasNewMarking(boolean show) {
//        SpUtils.obtain().save(SpConstant.HAS_NEW_MARKING, show);
//    }
//
//    public static boolean getFillInLight() {
//        return SpUtils.obtain().getBoolean(SpConstant.FILL_IN_LIGHT, false);
//    }
//
//    public static void setFillInLight(boolean show) {
//        SpUtils.obtain().save(SpConstant.FILL_IN_LIGHT, show);
//    }
//
//    public static boolean isBeautyHairColorNew() {
//        return SpUtils.obtain().getBoolean(SpConstant.BEAUTY_HAIR_COLOR_NEW, true);
//    }
//
//    public static void setBeautyHairColorNew(boolean show) {
//        SpUtils.obtain().save(SpConstant.BEAUTY_HAIR_COLOR_NEW, show);
//    }

    public static boolean isShowSelectMultiPreviewTip() {
        return SpUtils.obtain().getBoolean(SpConstant.SHOW_SELECT_MULTI_PREVIEW_TIP, false);
    }

    public static void setShowSelectMultiPreviewTip(boolean show) {
        SpUtils.obtain().save(SpConstant.SHOW_SELECT_MULTI_PREVIEW_TIP, show);
    }

//    public static boolean isShowSelectToEditPreviewTip() {
//        return SpUtils.obtain().getBoolean(SpConstant.SHOW_SELECT_TO_EDIT_PREVIEW_TIP, false);
//    }
//
//    public static void setShowSelectToEditPreviewTip(boolean show) {
//        SpUtils.obtain().save(SpConstant.SHOW_SELECT_TO_EDIT_PREVIEW_TIP, show);
//    }

    public static String getShareImageTool1PkgName(){
        return SpUtils.obtain().getString(SpConstant.LAST_SHARE_IMAGE_TOOL1_PKGNAME, null);
    }

    public static void setShareImageTool1PkgName(String name){
        SpUtils.obtain().save(SpConstant.LAST_SHARE_IMAGE_TOOL1_PKGNAME, name);
    }

    public static String getShareImageTool1ActivityName(){
        return SpUtils.obtain().getString(SpConstant.LAST_SHARE_IMAGE_TOOL1_ACTIVITY_NAME, null);
    }

    public static void setShareImageTool1ActivityName(String name){
        SpUtils.obtain().save(SpConstant.LAST_SHARE_IMAGE_TOOL1_ACTIVITY_NAME, name);
    }

    public static String getShareImageTool2PkgName(){
        return SpUtils.obtain().getString(SpConstant.LAST_SHARE_IMAGE_TOOL2_PKGNAME, null);
    }

    public static void setShareImageTool2PkgName(String name){
        SpUtils.obtain().save(SpConstant.LAST_SHARE_IMAGE_TOOL2_PKGNAME, name);
    }

    public static String getShareImageTool2ActivityName(){
        return SpUtils.obtain().getString(SpConstant.LAST_SHARE_IMAGE_TOOL2_ACTIVITY_NAME, null);
    }

    public static void setShareImageTool2ActivityName(String name){
        SpUtils.obtain().save(SpConstant.LAST_SHARE_IMAGE_TOOL2_ACTIVITY_NAME, name);
    }

    public static String getShareVideoTool1PkgName(){
        return SpUtils.obtain().getString(SpConstant.LAST_SHARE_VIDEO_TOOL1_PKGNAME, null);
    }

    public static void setShareVideoTool1PkgName(String name){
        SpUtils.obtain().save(SpConstant.LAST_SHARE_VIDEO_TOOL1_PKGNAME, name);
    }

    public static String getShareVideoTool1ActivityName(){
        return SpUtils.obtain().getString(SpConstant.LAST_SHARE_VIDEO_TOOL1_ACTIVITY_NAME, null);
    }

    public static void setShareVideoTool1ActivityName(String name){
        SpUtils.obtain().save(SpConstant.LAST_SHARE_VIDEO_TOOL1_ACTIVITY_NAME, name);
    }

    public static String getShareVideoTool2PkgName(){
        return SpUtils.obtain().getString(SpConstant.LAST_SHARE_VIDEO_TOOL2_PKGNAME, null);
    }

    public static void setShareVideoTool2PkgName(String name){
        SpUtils.obtain().save(SpConstant.LAST_SHARE_VIDEO_TOOL2_PKGNAME, name);
    }

    public static String getShareVideoTool2ActivityName(){
        return SpUtils.obtain().getString(SpConstant.LAST_SHARE_VIDEO_TOOL2_ACTIVITY_NAME, null);
    }

    public static void setShareVideoTool2ActivityName(String name){
        SpUtils.obtain().save(SpConstant.LAST_SHARE_VIDEO_TOOL2_ACTIVITY_NAME, name);
    }

    public static boolean getCollageNew() {
        return SpUtils.obtain().getBoolean(SpConstant.COLLAGE_NEW, false);
    }

    public static void setCollageNew(boolean show) {
        SpUtils.obtain().save(SpConstant.COLLAGE_NEW, show);
    }

    public static boolean getEditMagazineNew() {
        return SpUtils.obtain().getBoolean(SpConstant.EDIT_MAGAZINE_NEW, false);
    }

    public static void setEditMagazineNew(boolean show) {
        SpUtils.obtain().save(SpConstant.EDIT_MAGAZINE_NEW, show);
    }

    public static boolean getShowOtherBeautyRedIcon() {
        return SpUtils.obtain().getBoolean(SpConstant.SHOW_OTHER_BEAUTY_NEW_ICON, false);
    }

    public static void setShowOtherBeautyRedIcon(boolean show) {
        SpUtils.obtain().save(SpConstant.SHOW_OTHER_BEAUTY_NEW_ICON, show);
    }

    public static boolean getEditShowHairColorTip() {
        return SpUtils.obtain().getBoolean(SpConstant.EDIT_SHOW_HAIR_COLOR_TIP, false);
    }

    public static void setEditShowHairColorTip(boolean show) {
        SpUtils.obtain().save(SpConstant.EDIT_SHOW_HAIR_COLOR_TIP, show);
    }

    public static boolean getShowPreviewEditRedIcon() {
        return SpUtils.obtain().getBoolean(SpConstant.SHOW_PREVIEW_EDIT_RED_ICON, false);
    }

    public static void setShowPreviewEditRedIcon(boolean show) {
        SpUtils.obtain().save(SpConstant.SHOW_PREVIEW_EDIT_RED_ICON, show);
    }

    public static boolean getShowImgPreviewDynamicTip() {
        return SpUtils.obtain().getBoolean(SpConstant.SHOW_IMG_PREVIEW_DYNAMIC_TIP, false);
    }

    public static void setShowImgPreviewDynamicTip(boolean show) {
        SpUtils.obtain().save(SpConstant.SHOW_IMG_PREVIEW_DYNAMIC_TIP, show);
    }

    public static void saveInitCameraId(int id) {
        SpUtils.obtain().save(SpConstant.INIT_CAMERA_ID, id);
    }

    public static int getInitCameraId() {
        return SpUtils.obtain().getInt(SpConstant.INIT_CAMERA_ID, 1);
    }

    /**
     * 评分引导相关
     *
     */
    public static long getFirstInTimeOfDay(){
        return SpUtils.obtain().getLong(SpConstant.FIRST_IN_TIME_OF_DAY);
    }

    public static void setFirstInTimeOfDay(long time){
        SpUtils.obtain().save(SpConstant.FIRST_IN_TIME_OF_DAY, time);
    }

    public static int getOpenAppCountToday(){
        return SpUtils.obtain().getInt(SpConstant.OPEN_APP_CNT_PER_DAY, 0);
    }

    public static void setOpenAppCountToday(int count){
        SpUtils.obtain().save(SpConstant.OPEN_APP_CNT_PER_DAY, count);
    }

    public static int getShareCountOfDay(){
        return SpUtils.obtain().getInt(SpConstant.SHARE_CNT_PER_DAY, 0);
    }

    public static void setShareCountOfDay(int count){
        SpUtils.obtain().save(SpConstant.SHARE_CNT_PER_DAY, count);
    }

    public static int getDownloadCountToday(){
        return SpUtils.obtain().getInt(SpConstant.DOWNLOAD_CNT_PER_DAY, 0);
    }

    public static void setDownloadCountToday(int count){
        SpUtils.obtain().save(SpConstant.DOWNLOAD_CNT_PER_DAY, count);
    }

    public static String getFilterBuy(){
        return SpUtils.obtain().getString(SpConstant.ALREADY_BUY_FILTER_ID,"");
    }

    public static void setFilterBuy(String categoryId){
        String buy = SpUtils.obtain().getString(SpConstant.ALREADY_BUY_FILTER_ID,"");
        if(TextUtils.isEmpty(buy)){
            buy = categoryId;
        } else {
            buy += "#" + categoryId;
        }
        SpUtils.obtain().save(SpConstant.ALREADY_BUY_FILTER_ID,buy);
    }

    /**
     * 拍照或录制视频后，是否立即保持图片到相册
     * 1.03版本改成false，跳转到暂存编辑页面
     */
    public static boolean getSaveImgImmediately(){
        return SpUtils.obtain().getBoolean(SpConstant.SAVE_IMG_IMMEDIATELY, false);
    }

    public static void setSaveImgImmediately(boolean save){
        SpUtils.obtain().save(SpConstant.SAVE_IMG_IMMEDIATELY, save);
    }

    public static int getHolidayDBVersion(){
        return SpUtils.obtain().getInt(SpConstant.HOLIDAY_DB_VERSION, 0);
    }

    public static void setHolidayDBVersion(int version){
        SpUtils.obtain().save(SpConstant.HOLIDAY_DB_VERSION, version);
    }

    public static String getGifRecently(){
        return SpUtils.obtain().getString(SpConstant.GIF_RECENTLY, "");
    }

    public static void setGifRecently(String gifRecently){
        SpUtils.obtain().save(SpConstant.GIF_RECENTLY, gifRecently);
    }

    public static String getInsShareImgUri(){
        return SpUtils.obtain().getString(SpConstant.INS_SHARE_IMG_URI, "");
    }

    public static void setInsShareImgUri(String imgUri){
        if(TextUtils.isEmpty(imgUri)){
            SpUtils.obtain().save(SpConstant.INS_SHARE_IMG_URI, "");
        } else {
            SpUtils.obtain().save(SpConstant.INS_SHARE_IMG_URI, getInsShareImgUri() + imgUri + "#");
        }
    }

    public static void setBasicVideoInit(){
        SpUtils.obtain().save("BasicVideoInit", true);
    }

    public static boolean isBasicVideoInit(){
        return SpUtils.obtain().getBoolean("BasicVideoInit", false);
    }

    public static void setHasSaveGif(){
        SpUtils.obtain().save("HasSaveGif", true);
    }

    public static boolean hasSaveGif(){
        return SpUtils.obtain().getBoolean("HasSaveGif", false);
    }

    public static void setHasCheckPrivacy(){
        SpUtils.obtain().save(SpConstant.HAS_CHECK_PRIVACY, true);
    }

    public static boolean hasCheckPrivacy(){
        return SpUtils.obtain().getBoolean(SpConstant.HAS_CHECK_PRIVACY, false);
    }

    public static boolean showMainFuncListGuide() {
        return SpUtils.obtain().getBoolean(SpConstant.SHOW_MAIN_FUNC_LIST_GUIDE_TIP, true);
    }

    public static void setShowMainFuncListGuide(boolean show) {
        SpUtils.obtain().save(SpConstant.SHOW_MAIN_FUNC_LIST_GUIDE_TIP, show);
    }

    public static int getDownloadCountOfDay() {
        return SpUtils.obtain().getInt(SpConstant.STORE_DOWNLOAD_COUNT_OF_DAY, 0);
    }

    public static void addDownloadCountOfDay() {
        int i = getDownloadCountOfDay();
        SpUtils.obtain().save(SpConstant.STORE_DOWNLOAD_COUNT_OF_DAY, ++i);
    }

    public static void resetDownloadCountOfDay() {
        SpUtils.obtain().save(SpConstant.STORE_DOWNLOAD_COUNT_OF_DAY, 0);
    }

    public static boolean hasUseBoobJob() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_BOOBJOB, false);
    }

    public static void setHasUseBoobJob(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_BOOBJOB, use);
    }

    public static boolean hasUseButtocks() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_BUTTOCKS, false);
    }

    public static void setHasUseButtocks(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_BUTTOCKS, use);
    }

    public static boolean hasUseCollage() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_COLLAGE, false);
    }

    public static void setHasUseCollage(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_COLLAGE, use);
    }

    public static boolean hasUseGifSticker() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_GIF_STICKER, false);
    }

    public static void setHasUseGifSticker(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_GIF_STICKER, use);
    }

    public static boolean canShowGifSticker() {
        return SpUtils.obtain().getBoolean(SpConstant.CAN_SHOW_GIF_STICKER, false);
    }

    public static void setCanShowGifSticker(boolean can) {
        SpUtils.obtain().save(SpConstant.CAN_SHOW_GIF_STICKER, can);
    }

    public static boolean hasUseSticker() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_STICKER, false);
    }

    public static void setHasUseSticker(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_STICKER, use);
    }

    public static boolean hasUseHealing() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_HEALING, false);
    }

    public static void setHasUseHealing(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_HEALING, use);
    }

    public static boolean hasUseWhiten() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_WHITEN, false);
    }

    public static void setHasUseWhiten(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_WHITEN, use);
    }

    public static boolean hasUseMaleAbs() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_MALE_ABS, false);
    }

    public static void setHasUsMaleAbs(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_MALE_ABS, use);
    }

    public static boolean hasUseFemaleAbs() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_FEMALE_ABS, false);
    }

    public static void setHasUsFemaleAbs(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_FEMALE_ABS, use);
    }

    public static boolean hasUseSmooth() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_SMOOTH, false);
    }

    public static void setHasUseSmooth(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_SMOOTH, use);
    }

    public static boolean hasUseGlow() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_GLOW, false);
    }

    public static void setHasUseGlow(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_GLOW, use);
    }

    public static boolean hasUseHairColor() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_HAIR_COLOR, false);
    }

    public static void setHasUseHairColor(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_HAIR_COLOR, use);
    }

    public static boolean hasUseLipstick() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_LIPSTICK, false);
    }

    public static void setHasUseLipstick(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_LIPSTICK, use);
    }

    public static boolean hasUseEyeTuner() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_EYE_TUNER, false);
    }

    public static void setHasUseEyeTuner(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_EYE_TUNER, use);
    }

    public static boolean hasUseTaller() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_TALLER, false);
    }

    public static void setHasUseTaller(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_TALLER, use);
    }

    public static void saveLastShowTimeMainGuide() {
        SpUtils.obtain().save(SpConstant.LAST_SHOW_TIME_MAIN_GUIDE, System.currentTimeMillis());
    }

    public static long getLastShowTimeMainGuide() {
        return SpUtils.obtain().getLong(SpConstant.LAST_SHOW_TIME_MAIN_GUIDE, 0);
    }

    public static boolean hasUseMixer() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_USE_MIXER, false);
    }

    public static void setHasUseMixer(boolean use) {
        SpUtils.obtain().save(SpConstant.HAS_USE_MIXER, use);
    }

    public static boolean needShowByond30sVideoTip() {
        return SpUtils.obtain().getBoolean(SpConstant.SHOW_TIP_SEL_BEYOND_30S_VIDEO, true);
    }

    public static void setShowByond30sVideoTip(boolean show) {
        SpUtils.obtain().save(SpConstant.SHOW_TIP_SEL_BEYOND_30S_VIDEO, show);
    }

    public static boolean notifyStoreUpdateNeedPush() {
        return SpUtils.obtain().getBoolean(SpConstant.NOTIFY_STORE_UPDATE_NEED_PUSH, false);
    }

    public static void notifyStoreUpdateNeedPush(boolean need) {
        SpUtils.obtain().save(SpConstant.NOTIFY_STORE_UPDATE_NEED_PUSH, need);
    }

    public static String getNotifyStoreUpdateKey() {
        return SpUtils.obtain().getString(SpConstant.NOTIFY_STORE_UPDATE_KEY, "");
    }

    public static void setNotifyStoreUpdateKey(String key) {
        SpUtils.obtain().save(SpConstant.NOTIFY_STORE_UPDATE_KEY, key);
    }

    public static String getNotifyStoreUpdateIcon() {
        return SpUtils.obtain().getString(SpConstant.NOTIFY_STORE_UPDATE_LARGE_ICON, "");
    }

    public static void setNotifyStoreUpdateIcon(String icon) {
        SpUtils.obtain().save(SpConstant.NOTIFY_STORE_UPDATE_LARGE_ICON, icon);
    }

    public static boolean isEnterMainPageBefore() {
        return SpUtils.obtain().getBoolean(SpConstant.ENTER_MAIN_PAGE_BEFORE, false);
    }

    public static boolean isShowGuideAnimation() {
        return SpUtils.obtain().getBoolean(SpConstant.STATUS_SHOW_SVIP_GUIDE_ANIMATION, false);
    }

    public static void setShowGuideAnimation() {
        SpUtils.obtain().save(SpConstant.STATUS_SHOW_SVIP_GUIDE_ANIMATION, true);
    }

    public static void setEnterMainPageBefore() {
        SpUtils.obtain().save(SpConstant.ENTER_MAIN_PAGE_BEFORE, true);
    }

    public static long getNotifyStoreUpdateLastShowTime() {
        return SpUtils.obtain().getLong(SpConstant.NOTIFY_STORE_UPDATE_SHOW_TIME, 0);
    }

    public static void setNotifyStoreUpdateLastShowTime(long time) {
        SpUtils.obtain().save(SpConstant.NOTIFY_STORE_UPDATE_SHOW_TIME, time);
    }

    public static long getLastUseAppTime() {
        return SpUtils.obtain().getLong(SpConstant.LAST_USE_APP_TIME, System.currentTimeMillis());
    }

    public static void setLastUseAppTime(long time) {
        SpUtils.obtain().save(SpConstant.LAST_USE_APP_TIME, time);
    }

    public static long getLastSlientUserNotifyTime() {
        return SpUtils.obtain().getLong(SpConstant.LAST_SLIENT_USER_NOTIFY_TIME, System.currentTimeMillis());
    }

    public static void setLastSlientUserNotifyTime(long time) {
        SpUtils.obtain().save(SpConstant.LAST_SLIENT_USER_NOTIFY_TIME, time);
    }

    public static boolean isClickCollageBtn() {
        return SpUtils.obtain().getBoolean(SpConstant.CLICK_COLLAGE_BTN, false);
    }

    public static void setClickCollageBtn(boolean click) {
        SpUtils.obtain().save(SpConstant.CLICK_COLLAGE_BTN, click);
    }

    public static int getNotifyCollageTime() {
        return SpUtils.obtain().getInt(SpConstant.SHOW_NOTIFY_COLLAGE_TIME, 0);
    }

    public static void setNotifyCollageTime(int time) {
        SpUtils.obtain().save(SpConstant.SHOW_NOTIFY_COLLAGE_TIME, time);
    }

    public static boolean isSaveVideoCollage() {
        return SpUtils.obtain().getBoolean(SpConstant.SAVE_VIDEO_COLLAGE, false);
    }

    public static void setSaveVideoCollage(boolean save) {
        SpUtils.obtain().save(SpConstant.SAVE_VIDEO_COLLAGE, save);
    }

    public static int getNotifyVideoCollageTime() {
        return SpUtils.obtain().getInt(SpConstant.SHOW_NOTIFY_VIDEO_COLLAGE_TIME, 0);
    }

    public static void setNotifyVideoCollageTime(int time) {
        SpUtils.obtain().save(SpConstant.SHOW_NOTIFY_VIDEO_COLLAGE_TIME, time);
    }

    public static boolean isClickFressStyleBtn() {
        return SpUtils.obtain().getBoolean(SpConstant.CLICK_FREESTYLE_BTN, false);
    }

    public static void setClickFressStyleBtn(boolean click) {
        SpUtils.obtain().save(SpConstant.CLICK_FREESTYLE_BTN, click);
    }

    public static int getNotifyFreeStyleTime() {
        return SpUtils.obtain().getInt(SpConstant.SHOW_NOTIFY_FREESTYLE_TIME, 0);
    }

    public static void setNotifyFreeStyleTime(int time) {
        SpUtils.obtain().save(SpConstant.SHOW_NOTIFY_FREESTYLE_TIME, time);
    }

    public static boolean isSaveDynamicTemplate() {
        return SpUtils.obtain().getBoolean(SpConstant.SAVE_DYNAMIC_TEMPLATE, false);
    }

    public static void setSaveDynamicTemplate(boolean save) {
        SpUtils.obtain().save(SpConstant.SAVE_DYNAMIC_TEMPLATE, save);
    }

    public static int getNotifyDynamicTemplateTime() {
        return SpUtils.obtain().getInt(SpConstant.SHOW_NOTIFY_DYNAMIC_TEMPLATE_TIME, 0);
    }

    public static void setNotifyDynamicTemplateTime(int time) {
        SpUtils.obtain().save(SpConstant.SHOW_NOTIFY_DYNAMIC_TEMPLATE_TIME, time);
    }

    public static boolean isClickCropBtn() {
        return SpUtils.obtain().getBoolean(SpConstant.CLICK_CROP_BTN, false);
    }

    public static void setClickCropBtn(boolean click) {
        SpUtils.obtain().save(SpConstant.CLICK_CROP_BTN, click);
    }

    public static int getNotifyCropTime() {
        return SpUtils.obtain().getInt(SpConstant.SHOW_NOTIFY_CROP_TIME, 0);
    }

    public static void setNotifyCropTime(int time) {
        SpUtils.obtain().save(SpConstant.SHOW_NOTIFY_CROP_TIME, time);
    }

    public static boolean isSaveGif() {
        return SpUtils.obtain().getBoolean(SpConstant.SAVE_GIF, false);
    }

    public static void setSaveGif(boolean save) {
        SpUtils.obtain().save(SpConstant.SAVE_GIF, save);
    }

//    public static int getNotifySaveGifTime() {
//        return SpUtils.obtain().getInt(SpConstant.SHOW_NOTIFY_GIF_TIME, 0);
//    }
//
//    public static void setNotifySaveGifTime(int time) {
//        SpUtils.obtain().save(SpConstant.SHOW_NOTIFY_GIF_TIME, time);
//    }
//
//    public static boolean isShowVideoCollageGuideAgain() {
//        return SpUtils.obtain().getBoolean(SpConstant.SHOW_VIDEO_COLLAGE_GUIDE_AGAIN, false);
//    }
//
//    public static void setShowVideoCollageGuideAgain(boolean show) {
//        SpUtils.obtain().save(SpConstant.SHOW_VIDEO_COLLAGE_GUIDE_AGAIN, show);
//    }
//
//    public static boolean isShowGifGuideAgain() {
//        return SpUtils.obtain().getBoolean(SpConstant.SHOW_VIDEO_GIF_GUIDE_AGAIN, false);
//    }
//
//    public static void setShowGifGuideAgain(boolean show) {
//        SpUtils.obtain().save(SpConstant.SHOW_VIDEO_GIF_GUIDE_AGAIN, show);
//    }
//
//    public static void setShowHolidayNotifTime(long time) {
//        SpUtils.obtain().save(SpConstant.LAST_SHOW_HOLIDAY_NOTIF_TIME, time);
//    }
//
//    public static long getLastShowHolidayNotifTime() {
//        return SpUtils.obtain().getLong(SpConstant.LAST_SHOW_HOLIDAY_NOTIF_TIME, 0);
//    }
//
//    public static String getShowHolidayNotifTitle() {
//        return SpUtils.obtain().getString(SpConstant.LAST_SHOW_HOLIDAY_TITLE, ComponentContext.getContext().getResources().getString(R.string.notify_holiday_title));
//    }
//
//    public static void setShowHolidayNotifTitle(String title) {
//        SpUtils.obtain().save(SpConstant.LAST_SHOW_HOLIDAY_TITLE, title);
//    }
//
//    public static String getShowHolidayNotifContent() {
//        return SpUtils.obtain().getString(SpConstant.LAST_SHOW_HOLIDAY_CONTENT, ComponentContext.getContext().getResources().getString(R.string.notify_holiday_content));
//    }
//
//    public static void setShowHolidayNotifContent(String title) {
//        SpUtils.obtain().save(SpConstant.LAST_SHOW_HOLIDAY_CONTENT, title);
//    }
//
//    public static int getShowHolidayNotifDayOfWeek() {
//        return SpUtils.obtain().getInt(SpConstant.LAST_SHOW_HOLIDAY_DAY_OF_WEEK, 6);
//    }
//
//    public static void setShowHolidayNotifDayOfWeek(int dayOfWeek) {
//        SpUtils.obtain().save(SpConstant.LAST_SHOW_HOLIDAY_DAY_OF_WEEK, dayOfWeek);
//    }
//
//    public static int getShowHolidayNotifStartHour() {
//        return SpUtils.obtain().getInt(SpConstant.LAST_SHOW_HOLIDAY_HOUR_START, 19);
//    }
//
//    public static void setShowHolidayNotifStartHour(int startHour) {
//        SpUtils.obtain().save(SpConstant.LAST_SHOW_HOLIDAY_HOUR_START, startHour);
//    }
//
//    public static int getShowHolidayNotifEndHour() {
//        return SpUtils.obtain().getInt(SpConstant.LAST_SHOW_HOLIDAY_HOUR_END, 21);
//    }
//
//    public static void setShowHolidayNotifEndHour(int startHour) {
//        SpUtils.obtain().save(SpConstant.LAST_SHOW_HOLIDAY_HOUR_END, startHour);
//    }
//
//    public static String getShowHolidayNotifIcon() {
//        return SpUtils.obtain().getString(SpConstant.LAST_SHOW_HOLIDAY_ICON, "");
//    }
//
//    public static void setShowHolidayNotifIcon(String iconUrl) {
//        SpUtils.obtain().save(SpConstant.LAST_SHOW_HOLIDAY_ICON, iconUrl);
//    }

    public static void setEnableNotifacation(boolean enable) {
        SpUtils.obtain().save(SpConstant.ENABLE_NOTIFICATION, enable);
    }

    public static boolean enableNotifacation() {
        return SpUtils.obtain().getBoolean(SpConstant.ENABLE_NOTIFICATION, false);
    }

    public static boolean needShowSplashAd() {
        return SpUtils.obtain().getBoolean(SpConstant.NEED_SHOW_SPLASH_AD, false);
    }

    public static void setNeedShowSplashAd() {
        SpUtils.obtain().save(SpConstant.NEED_SHOW_SPLASH_AD, true);
    }

    public static boolean isNeedShowFreeSVIP() {
        return SpUtils.obtain().getBoolean(SpConstant.NEED_SHOW_FREE_SVIP, true);
    }

    public static void setIsNeedShowFreeSVIP(boolean need) {
        SpUtils.obtain().save(SpConstant.NEED_SHOW_FREE_SVIP, need);
    }

    public static long getLastTimeIntoMain() {
        return SpUtils.obtain().getLong(SpConstant.LAST_TIME_INTO_MAIN, System.currentTimeMillis());
    }

    public static void setLastTimeIntoMain(long time) {
        SpUtils.obtain().save(SpConstant.LAST_TIME_INTO_MAIN, time);
    }

//    public static boolean hasShowFreeSVIPOver24() {
//        return SpUtils.obtain().getBoolean(SpConstant.HAS_SHOW_LIMIT_FREE_OVER_24, false);
//    }
//
//    public static void setHasShowFreeSVIPOver24() {
//        SpUtils.obtain().save(SpConstant.HAS_SHOW_LIMIT_FREE_OVER_24, true);
//    }
//
//    public static int getLastBannerPosition() {
//        return SpUtils.obtain().getInt(SpConstant.LAST_BANNER_POSITION, -1);
//    }
//
//    public static void setLastBannerPosition(int pos) {
//        SpUtils.obtain().save(SpConstant.LAST_BANNER_POSITION, pos);
//    }
//
//    public static boolean isShowDefaultBanner() {
//        return SpUtils.obtain().getBoolean(SpConstant.SHOW_DEFAULT_BANNER, true);
//    }
//
//    public static void setHasShowDefaultBanner() {
//        SpUtils.obtain().save(SpConstant.SHOW_DEFAULT_BANNER, false);
//    }
//
//    public static void setCanShowStoragePermissionDialog(boolean show) {
//        SpUtils.obtain().save(SpConstant.SHOW_STORAGE_PERMISSION_DIALOG, show);
//    }
//
//    public static boolean canShowStoragePermissionDialog() {
//        return SpUtils.obtain().getBoolean(SpConstant.SHOW_STORAGE_PERMISSION_DIALOG, true);
//    }
//
//    public static void setUpgradeFromTargetsdkversion22(boolean yes) {
//        SpUtils.obtain().save(SpConstant.UPGRADE_FROM_TARGET_SDK_VERSION_22, yes);
//    }
//
//    public static boolean isUpgradeFromTargetsdkversion22() {
//        return SpUtils.obtain().getBoolean(SpConstant.UPGRADE_FROM_TARGET_SDK_VERSION_22, false);
//    }
//
//    public static void setHasCheckTargetsdkversion(boolean check) {
//        SpUtils.obtain().save(SpConstant.HAS_CHECK_TARGET_SDK_VERSION, check);
//    }
//
//    public static boolean hasCheckTargetsdkversion() {
//        return SpUtils.obtain().getBoolean(SpConstant.HAS_CHECK_TARGET_SDK_VERSION, false);
//    }
//
//    public static void setCanShowFloatWindowPermissionDialog(boolean show) {
//        SpUtils.obtain().save(SpConstant.REQ_FLOATWINDOW_PERMISSION, show);
//    }
//
//    public static boolean canShowFloatWindowPermissionDialog() {
//        return SpUtils.obtain().getBoolean(SpConstant.REQ_FLOATWINDOW_PERMISSION, true);
//    }

    /**
     * 统计的功能入口
     * @param entrance
     */
    public static void setFunctionEntrance(String entrance) {
        SpUtils.obtain().save(SpConstant.FUNCTION_ENTRANCE, entrance);
    }

    public static String getFunctionEntrance() {
        return SpUtils.obtain().getString(SpConstant.FUNCTION_ENTRANCE, "no_function");
    }

    /**
     * 是否首次进入编辑页
     * @param isFirstEnterFeature
     */
    public static void setIsFirstEnterFeature(boolean isFirstEnterFeature) {
        SpUtils.obtain().save(SpConstant.IS_FIRST_ENTER_FEATURE, isFirstEnterFeature);
    }

    public static boolean getIsFirstEnterFeature() {
        return SpUtils.obtain().getBoolean(SpConstant.IS_FIRST_ENTER_FEATURE, true);
    }

    /**
     * 是否首次在编辑页保存
     * @param isFirstSaveFeature
     */
    public static void setIsFirstSaveFeature(boolean isFirstSaveFeature) {
        SpUtils.obtain().save(SpConstant.IS_FIRST_SAVE_FEATURE, isFirstSaveFeature);
    }

    public static boolean getIsFirstSaveFeature() {
        return SpUtils.obtain().getBoolean(SpConstant.IS_FIRST_SAVE_FEATURE, true);
    }

    /**
     * 统计的功能入口
     * @param saveFunctionName
     */
    public static void setSaveFunctionName(String saveFunctionName) {
        SpUtils.obtain().save(SpConstant.SAVE_FUNCTION_NAME, saveFunctionName);
    }

    public static String getSaveFunctionName() {
        return SpUtils.obtain().getString(SpConstant.SAVE_FUNCTION_NAME, "no_function");
    }

    /**
     * 艺术滤镜是否可用
     * @param artistAvailable
     */
    public static void setArtistAvailable(boolean artistAvailable) {
        SpUtils.obtain().save(SpConstant.ARTIST_AVAILABLE, artistAvailable);
    }

    public static boolean getArtistAvailable() {
        return SpUtils.obtain().getBoolean(SpConstant.ARTIST_AVAILABLE, true);
    }

    /**
     * 上次统计留存时间
     * @param retentionLastTime
     */
    public static void setRetentionLastTime(long retentionLastTime) {
        SpUtils.obtain().save(SpConstant.RETENTION_LAST_TIME, retentionLastTime);
    }

    public static long getRetentionLastTime() {
        return SpUtils.obtain().getLong(SpConstant.RETENTION_LAST_TIME, 0);
    }

    public static void setArtistEnable(boolean enable) {
        SpUtils.obtain().save(SpConstant.ARTIST_ENABLE, enable);
    }

    public static boolean getArtistEnable() {
        return SpUtils.obtain().getBoolean(SpConstant.ARTIST_ENABLE, true);
    }

    /**
     * 是否打开vip测试开关
     */
    public static boolean getIsSvipSwithOn() {
        return SpUtils.obtain().getBoolean(SpConstant.SVIP_SWITCH_ON, false);
    }

    public static void setIsSvipSwithOn(boolean isSvipSwithOn) {
        SpUtils.obtain().save(SpConstant.SVIP_SWITCH_ON, isSvipSwithOn);
    }

    /**
     *   广告一次性VIP
     */
    public static boolean getAdOneTimeVip() {
        return SpUtils.obtain().getBoolean(SpConstant.KEY_ONE_TIME_VIP, false);
    }

    public static void setAdOneTimeVip(boolean adOneTimeVip) {
        SpUtils.obtain().save(SpConstant.KEY_ONE_TIME_VIP, adOneTimeVip);
    }

    /**
     * 引导五星得一天VIP
     */
    public static void setOneDayVipTime() {
        SpUtils.obtain().save(SpConstant.KEY_ONE_DAY_VIP, System.currentTimeMillis());
    }

    public static long getOneDayVipTime() {
        return SpUtils.obtain().getLong(SpConstant.KEY_ONE_DAY_VIP, -1);
    }

    public static boolean isOneDayVip() {
        return System.currentTimeMillis() - getOneDayVipTime() <= 24 * 60 * 60 * 1000;
    }

    public static String getLanguage() {
        return SpUtils.obtain().getString(SpConstant.LANGUAGE);
    }

    public static void setLanguage(String language) {
        SpUtils.obtain().save(SpConstant.LANGUAGE, language);
    }

    public static String getCountry() {
        return SpUtils.obtain().getString(SpConstant.COUNTRY);
    }

    public static void setCountry(String country) {
        SpUtils.obtain().save(SpConstant.COUNTRY, country);
    }

    /**
     * 某个功能使用后，保存sp
     * @param funId
     */
    public static void saveFunUseByFunId(int funId) {
        DLog.d("useLog", "use funId: " + funId);
        SpUtils.obtain().save(String.valueOf(funId), true);
    }

    public static boolean getFunIsUsed(int funId) {
        DLog.d("useLog", "query funId: " + funId);
        return SpUtils.obtain().getBoolean(String.valueOf(funId), false);
    }

    /**
     * 获取某个功能结果页面中，上次推荐的功能名称
     * @param funId
     */
    public static void saveLastRecommendByFunId(int funId, String name) {
        SpUtils.obtain().save("last_show_fun_" + String.valueOf(funId), name);
    }

    public static String getLastRecommendByFunId(int funId) {
        return SpUtils.obtain().getString("last_show_fun_" + String.valueOf(funId), "");
    }

    /**
     * 进入到结果页的次数自加1
     * 注意：展示星座功能的结果时不加1
     */
    public static void addComeToResultPageCount() {
        int num = getComeToResultPageCount();
        num++;
        SpUtils.obtain().save(SpConstant.COME_TO_RESULT_PAGE_COUNT, num);
    }

    /**
     * 获取进入到结果页的次数
     */
    public static int getComeToResultPageCount() {
        return SpUtils.obtain().getInt(SpConstant.COME_TO_RESULT_PAGE_COUNT, 0);
    }

    /**
     * 获取当日用过的功能种类，返回格式: aaa#bbb#ccc，即当天使用过3种功能
     * @return
     */
    private static String getUseFuncTypeToday() {
        return SpUtils.obtain().getString(SpConstant.USE_FUN_TYPE_TODAY, "");
    }

    /**
     * 获取用过的功能种类，返回格式: aaa#bbb#ccc，即当天使用过3种功能
     * @return
     */
    private static String getUseFuncType() {
        return SpUtils.obtain().getString(SpConstant.USR_FUN, "");
    }

    /**
     * 记录使用的功能
     * @param type
     */
    public static void addUseFunTypeToday(String type) {
        addUseFunType(type);
        String recordTypes = getUseFuncTypeToday();
        if (recordTypes == null || recordTypes.equals("")) {//当日还没使用过任何功能
            SpUtils.obtain().save(SpConstant.USE_FUN_TYPE_TODAY, type);
            DLog.d(TAG, "record type: " + type);
        } else {
            if (isTypeRecorded(type, recordTypes)) {//已经用过该功能，则不记录
                return;
            } else {//当日还未使用过该功能，记录该功能
                StringBuilder sb = new StringBuilder();
                sb.append(recordTypes).append("#").append(type);
                SpUtils.obtain().save(SpConstant.USE_FUN_TYPE_TODAY, sb.toString());
                DLog.d(TAG, "record type: " + sb.toString());
            }
        }
    }

    /**
     * 记录使用的功能
     * @param type
     */
    public static void addUseFunType(String type) {
        String recordTypes = getUseFuncType();
        if (recordTypes == null || recordTypes.equals("")) {//当日还没使用过任何功能
            SpUtils.obtain().save(SpConstant.USR_FUN, type);
            DLog.d(TAG, "record type: " + type);
        } else {
            if (isTypeRecorded(type, recordTypes)) {//已经用过该功能，则不记录
                return;
            } else {//当日还未使用过该功能，记录该功能
                StringBuilder sb = new StringBuilder();
                sb.append(recordTypes).append("#").append(type);
                SpUtils.obtain().save(SpConstant.USR_FUN, sb.toString());
                DLog.d(TAG, "record type: " + sb.toString());
            }
        }
    }

    private static boolean isTypeRecorded(String type, String recordTypes) {
        String[] typeArray = recordTypes.split("#");
        for (String tmp : typeArray) {
            if (tmp.equals(type)) return true;
        }
        return false;
    }

    /**
     * 清除已记录过的功能
     */
    public static void clearUseFunTypeToday() {
        SpUtils.obtain().save(SpConstant.USE_FUN_TYPE_TODAY, "");
        SpUtils.obtain().save(SpConstant.USE_HOROSCOPE_TODAY, "");
    }

    public static void clearUseHoroscopeAfterUseFree(){
        SpUtils.obtain().save(SpConstant.USE_HOROSCOPE_BEFORE_FREE_FUN, false);
    }

    public static String getUseFuncType(int type) {
        String ret = null;
        switch (type) {
            case BaseFaceResultBean.REPORT_TYPE_FACE_AGING:
                ret = SpConstant.FUNC_TYPE_FACE_AGING;
                break;
            /*case CompatibilityActivity.TYPE_HOROSCOPE:
                ret = SpConstant.FUNC_TYPE_ZODIAC_COMPABILITY;
                break;
            case CompatibilityActivity.TYPE_LOVE:
                ret = SpConstant.FUNC_TYPE_LOVE_COMPABILITY;
                break;
            case CrystalBallActivity.TYPE_CRYSTALL:
                ret = SpConstant.FUNC_TYPE_CRYSTALBALL;
                break;
            case LuckActivity.TYPE_LUCKY:
                ret = SpConstant.FUNC_TYPE_LUCKY;
                break;
            case HoroscopeActivity.TYPE_HOROSCOPE:
                ret = SpConstant.FUNC_TYPE_HOROSCOPE;
                break;*/
            default:
                break;
        }
        return ret;
    }

    public static boolean canRateBase() {
        return  !getTodayHasRated() && !hasRated();
    }

    /**
     * 一天最多显示一次
     */
    public static boolean getTodayHasRated(){
        return DateUtils.getTodayString().equals(
                SpUtils.obtain().getString(SpConstant.TODAY_HAS_RATED_KEY, "no_rate"));
    }

    public static void setTodayHasRated(){
        SpUtils.obtain().save(SpConstant.TODAY_HAS_RATED_KEY, DateUtils.getTodayString());
    }

    public static boolean hasRated(){
        return SpUtils.obtain().getBoolean(SpConstant.FUNC_IS_EVER_RATE, false);
    }

    public static void setHasRated(){
        SpUtils.obtain().save(SpConstant.FUNC_IS_EVER_RATE, true);
    }

    /**
     * 是否进入过预测宝宝
     */
//    public static void setIsEnteredBaby(boolean isEnteredBaby) {
//        SpUtils.obtain().save(SpConstant.IS_ENTERED_BABY, isEnteredBaby);
//    }
//
//    public static boolean getIsEnteredBaby() {
//        return SpUtils.obtain().getBoolean(SpConstant.IS_ENTERED_BABY, false);
//    }
//
//    /**
//     * 是否进入过变老
//     */
//    public static void setIsEnteredOld(boolean isEnteredOld) {
//        SpUtils.obtain().save(SpConstant.IS_ENTERED_OLD, isEnteredOld);
//    }
//
//    public static boolean getIsEnteredOld() {
//        return SpUtils.obtain().getBoolean(SpConstant.IS_ENTERED_OLD, false);
//    }
//
//    /**
//     * 是否进入过种族分析
//     */
//    public static void setIsEnteredEthnicity(boolean isEnteredEthnicity) {
//        SpUtils.obtain().save(SpConstant.IS_ENTERED_ETHNICITY, isEnteredEthnicity);
//    }
//
//    public static boolean getIsEnteredEthnicity() {
//        return SpUtils.obtain().getBoolean(SpConstant.IS_ENTERED_ETHNICITY, false);
//    }
//
//    /**
//     * 是否进入过异域风情
//     */
//    public static void setIsEnteredExotic(boolean isEnteredExotic) {
//        SpUtils.obtain().save(SpConstant.IS_ENTERED_EXOTIC, isEnteredExotic);
//    }
//
//    public static boolean getIsEnteredExotic() {
//        return SpUtils.obtain().getBoolean(SpConstant.IS_ENTERED_EXOTIC, false);
//    }
//
//    /**
//     * 是否进入过前世今生
//     */
//    public static void setIsEnteredPreviousLife(boolean isEnteredPreviousLife) {
//        SpUtils.obtain().save(SpConstant.IS_ENTERED_PREVIOUS_LIFE, isEnteredPreviousLife);
//    }
//
//    public static boolean getIsEnteredPreviousLife() {
//        return SpUtils.obtain().getBoolean(SpConstant.IS_ENTERED_PREVIOUS_LIFE, false);
//    }
//
//    /**
//     * 是否进入过性别转换
//     */
//    public static void setIsEnteredGenderSwitch(boolean isEnteredGenderSwitch) {
//        SpUtils.obtain().save(SpConstant.IS_ENTERED_GENDER_SWITCH, isEnteredGenderSwitch);
//    }
//
//    public static boolean getIsEnteredGenderSwitch() {
//        return SpUtils.obtain().getBoolean(SpConstant.IS_ENTERED_GENDER_SWITCH, false);
//    }
//
//    /**
//     * 是否进入过预测未来
//     */
//    public static void setIsEnteredFuture(boolean isEnteredFuture) {
//        SpUtils.obtain().save(SpConstant.IS_ENTERED_FUTURE, isEnteredFuture);
//    }
//
//    public static boolean getIsEnteredFuture() {
//        return SpUtils.obtain().getBoolean(SpConstant.IS_ENTERED_FUTURE, false);
//    }

    /**
     * 一天免费弹框是否显示
     */
    public static boolean getIsShowObtainVipDialog() {
        return SpUtils.obtain().getBoolean(SpConstant.IS_SHOW_OBTAIN_VIP_DIALOG, true);
    }

    public static void setIsShowObtainVipDialog(boolean isShowObtainVipDialog) {
        SpUtils.obtain().save(SpConstant.IS_SHOW_OBTAIN_VIP_DIALOG, isShowObtainVipDialog);
    }

    /**
     * 广告弹框是否显示
     */
    public static boolean getIsShowAdvanceDialog() {
        return SpUtils.obtain().getBoolean(SpConstant.IS_SHOW_ADVANCE_DIALOG, true);
    }

    public static void setIsShowAdvanceDialog(boolean isShowAdvanceDialog) {
        SpUtils.obtain().save(SpConstant.IS_SHOW_ADVANCE_DIALOG, isShowAdvanceDialog);
    }

    public static boolean isFirstCloseSubsPage() {
        return isFirstCloseFeatureSubsPage() && isFirstCloseToolSubsPage() && isFirstCloseMaterialSubsPage();
    }

    public static boolean isFirstCloseFeatureSubsPage() {
        return SpUtils.obtain().getBoolean(SpConstant.IS_FIRST_IN_FEATURE_SUBS_PAGE, true);
    }

    public static void closeFeatureSubsPage() {
        SpUtils.obtain().save(SpConstant.IS_FIRST_IN_FEATURE_SUBS_PAGE, false);
    }

    public static boolean isFirstCloseToolSubsPage() {
        return SpUtils.obtain().getBoolean(SpConstant.IS_FIRST_IN_TOOL_SUBS_PAGE, true);
    }

    public static void closeToolSubsPage() {
        SpUtils.obtain().save(SpConstant.IS_FIRST_IN_TOOL_SUBS_PAGE, false);
    }

    public static boolean isFirstCloseMaterialSubsPage() {
        return SpUtils.obtain().getBoolean(SpConstant.IS_FIRST_IN_MATERIAL_SUBS_PAGE, true);
    }

    public static void closeMaterialSubsPage() {
        SpUtils.obtain().save(SpConstant.IS_FIRST_IN_MATERIAL_SUBS_PAGE, false);
    }

    private static boolean isFirstInAdvanceResultPage;
    public static void comeIn() {
        isFirstInAdvanceResultPage = SpUtils.obtain().getBoolean(SpConstant.FIRST_IN_ADVANCE_RESULT_PAGE, true);
        SpUtils.obtain().save(SpConstant.FIRST_IN_ADVANCE_RESULT_PAGE, false);
    }

    public static boolean isFirstInAdvanceResultPage() {
        return isFirstInAdvanceResultPage;
    }


    public static void hasShowedAdVideoDialogInAdvanceResultPage() {
        SpUtils.obtain().save(SpConstant.HAS_SHOWED_AD_VIDEO_DIALOG_IN_ADVANCE_RESULT_PAGE, true);
    }

    public static boolean whetherShowedAdVideoDialogInAdvanceResultPage() {
        return SpUtils.obtain().getBoolean(SpConstant.HAS_SHOWED_AD_VIDEO_DIALOG_IN_ADVANCE_RESULT_PAGE, false);
    }

    public static void showSubscribeActivity() {
        SpUtils.obtain().save(SpConstant.SHOW_SUBSCRIBE_ACTIVITY_TIME,
                SpUtils.obtain().getInt(SpConstant.SHOW_SUBSCRIBE_ACTIVITY_TIME, 0) + 1);
    }

    public static int getSubscribeActivityShowTime() {
        return SpUtils.obtain().getInt(SpConstant.SHOW_SUBSCRIBE_ACTIVITY_TIME, 0);
    }

    public static void showTodayAllSubscribeMask() {
        String countAndDate = SpUtils.obtain().getString(SpConstant.SHOW_SUBSCRIBE_MASK_COUNT_AND_DATE);
        boolean reset = false;
        int count = 0;
        if (TextUtils.isEmpty(countAndDate)) {
            reset = true;
        } else {
            String[] array = countAndDate.split("_");
            if (array == null || array.length != 2) {
                reset = true;
            } else {
                String countStr = array[0];
                String dayStr = array[1];
                count = Integer.valueOf(countStr);
                Date date = new Date(Long.valueOf(dayStr));
                Date dateToday = new Date(System.currentTimeMillis());
                if (!DateUtils.isSameDay(date, dateToday)) {
                    reset = true;
                }
            }
        }
        String value;
        if (reset) {
            value = "1_" + String.valueOf(System.currentTimeMillis());
        } else {
            value = String.valueOf(count+1) + "_" + String.valueOf(System.currentTimeMillis());
        }
        SpUtils.obtain().save(SpConstant.SHOW_SUBSCRIBE_MASK_COUNT_AND_DATE, value);
    }

    public static int getTodayHasShowedAllSubscribeMaskCount() {
        String countAndDate = SpUtils.obtain().getString(SpConstant.SHOW_SUBSCRIBE_MASK_COUNT_AND_DATE);
        if (TextUtils.isEmpty(countAndDate)) {
            return 0;
        }
        String[] array = countAndDate.split("_");
        if (array == null || array.length != 2) {
            return 0;
        } else {
            String countStr = array[0];
            String dayStr = array[1];
            return Integer.valueOf(countStr);
        }
    }

    public static void showTodayNorStickersSubscribeMask() {
        String countAndDate = SpUtils.obtain().getString(SpConstant.SHOW_NOR_STICKERS_SUBSCRIBE_MASK_COUNT_AND_DATE);
        boolean reset = false;
        int count = 0;
        if (TextUtils.isEmpty(countAndDate)) {
            reset = true;
        } else {
            String[] array = countAndDate.split("_");
            if (array == null || array.length != 2) {
                reset = true;
            } else {
                String countStr = array[0];
                String dayStr = array[1];
                count = Integer.valueOf(countStr);
                Date date = new Date(Long.valueOf(dayStr));
                Date dateToday = new Date(System.currentTimeMillis());
                if (!DateUtils.isSameDay(date, dateToday)) {
                    reset = true;
                }
            }
        }
        String value;
        if (reset) {
            value = "1_" + String.valueOf(System.currentTimeMillis());
        } else {
            value = String.valueOf(count+1) + "_" + String.valueOf(System.currentTimeMillis());
        }
        SpUtils.obtain().save(SpConstant.SHOW_NOR_STICKERS_SUBSCRIBE_MASK_COUNT_AND_DATE, value);
    }

    public static int getTodayHasShowedNorStickersSubscribeMaskCount() {
        String countAndDate = SpUtils.obtain().getString(SpConstant.SHOW_NOR_STICKERS_SUBSCRIBE_MASK_COUNT_AND_DATE);
        if (TextUtils.isEmpty(countAndDate)) {
            return 0;
        }
        String[] array = countAndDate.split("_");
        if (array == null || array.length != 2) {
            return 0;
        } else {
            String countStr = array[0];
            String dayStr = array[1];
            return Integer.valueOf(countStr);
        }
    }


}
